﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using MLY;

namespace MLY.Bll
{
  public class tblLogger
  {
    static Dal.lqKbmDataContext dc = new Dal.lqKbmDataContext();

    public static void AddLogEntry(string msg, bool isError)
    {
      try
      {
        if (isError)
          Log.WriteError(msg);
        else
          Log.WriteInfo(msg);
        Dal.logTbl lg = new MLY.Dal.logTbl();
        int lstIdx = (from p in dc.logTbls orderby p.Idx descending select p.Idx).FirstOrDefault();
        lg.Idx = lstIdx + 2;
        lg.Message = msg;
        lg.isError = isError;
        lg.timeReceived = DateTime.Now;
        dc.logTbls.InsertOnSubmit(lg);
        dc.SubmitChanges();
      }
      catch
      { }
    }
  }
}
